import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';

export default async function upload(fd: IFeidaoAiBrowserComponent, node: HTMLInputElement) {

	const file = node.files[0];
	// const file_name = file.name;
	const r = new FileReader();
	r.readAsDataURL(file);
	return new Promise((resolve, reject) => {
		r.onload = async (e) => {
			const data = (e.target as any).result as string;
			resolve(data);
		};
		r.onerror = async (e) => {
			reject('fail');
		};
	});
}
